module.exports = (grunt) ->
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    coffee: coffee,
    compass: compass,
    less: less,
    uglify: uglify,
    watch: watch,
  })
  grunt.loadNpmTasks('grunt-contrib-coffee')
  grunt.loadNpmTasks('grunt-contrib-compass')
  grunt.loadNpmTasks('grunt-contrib-less')
  grunt.loadNpmTasks('grunt-contrib-uglify')
  grunt.loadNpmTasks('grunt-contrib-watch')

  grunt.registerTask('default', ['coffee', 'compass', 'uglify', 'watch'])

watch = 
  compass: 
    files: ['app/sass/**/*.scss', 'app/sass/**/*.sass']
    tasks: ['compass']
  less: 
    files: ['app/less/**/*.less']
    tasks: ['less']
  coffee: 
    files: ['app/coffee/*.coffee']
    tasks: ['coffee']

uglify = 
  options: 
    beautify: true
    banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
  build: 
    src: 'build/js/*.js',
    dest: 'build/<%= pkg.name %>.min.js'

compass = 
  dist:           
    options: 
      config: 'app/sass/config.rb'

less =
  development:
    options:
      paths: "app/less"
    files:
      "build/css/main.css": "app/less/main.less",

coffee = 
  glob_to_multiple:
    options:
      bare: false
      sourceMap: true
    expand: true
    cwd: 'app/coffee'
    src: ['*.coffee']
    dest: 'build/js/'
    ext: '.js'
